<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<t:base type="jquery,easyui,tools"></t:base>
<div id="main_typegroup_list" class="easyui-layout" fit="true">
  <div region="center" style="padding: 1px;">
    <t:datagrid name="businessList" title=""  fitColumns="false" actionUrl="questionsController.do?datagrid"
                fit="true" idField="questionsId" sortOrder="desc" sortName="quesTime"
                queryMode="group" onLoadSuccess="loadSuccess">
      <t:dgCol title="id" field="questionsId" hidden="true"></t:dgCol>
      <t:dgCol title="提问标题"   field="title"  query="true"  extendParams="formatter:f_substring;" ></t:dgCol>
      <t:dgCol title="提问内容"   field="content"  extendParams="formatter:f_substring;" ></t:dgCol>
      <t:dgCol title="提问时间"  formatter="yyyy-MM-dd hh:mm:ss" field="quesTime"></t:dgCol>
      <t:dgCol title="提问人"   field="customer.nickname" query="true"></t:dgCol>
      <t:dgCol title="提问人手机号"   field="customer.phone" query="true" hidden="true"></t:dgCol>
      <t:dgCol title="回复数"   field="reply" ></t:dgCol>

      <t:dgCol title="common.operation" field="opt" ></t:dgCol>
      <t:dgDelOpt url="questionsController.do?del&id={questionsId}" title="删除" operationCode="delOperation"></t:dgDelOpt>
      <t:dgFunOpt title="查看问答详情" exp="reply#ne#0" funname="f_optDetail(questionsId)"></t:dgFunOpt>
      <%--<t:dgToolBar title="新增" operationCode="addOperation" langArg="common.user" icon="icon-add" url="questionsController.do?addorupdate" width="850" height="550" funname="add"></t:dgToolBar>--%>
      <%--<t:dgToolBar title="修改" operationCode="editOperation" langArg="common.user" icon="icon-edit" url="questionsController.do?addorupdate" width="850" height="550" funname="f_updateBusiness"></t:dgToolBar>--%>
    </t:datagrid>
  </div>
</div>
<div data-options="region:'east',
	title:'mytitle',
	collapsed:true,
	split:true,
	border:false,
	onExpand : function(){
		li_east = 1;
	},
	onCollapse : function() {
	    li_east = 0;
	}"
     style="width: 400px; overflow: hidden;" id="eastPanel">
  <div class="easyui-panel" style="padding: 1px;" fit="true" border="false" id="listpanel"></div>
</div>


<script type="text/javascript">

  $(function() {
    var li_east = 0;
  });

  /**
   * 重写 更新事件打开窗口
   * @param title 编辑框标题
   * @param addurl//目标页面地址
   * @param id//主键字段
   */
  function f_updateBusiness(title,url, id,width,height) {
    gridname=id;
    var rowsData = $('#'+id).datagrid('getSelections');
    if (!rowsData || rowsData.length==0) {
      tip('请选择编辑项目');
      return;
    }
    if (rowsData.length>1) {
      tip('请选择一条记录再编辑');
      return;
    }

    url += '&carId='+rowsData[0].carId;
    createwindow(title,url,width,height);
  }


  function f_substring(val,row){
    var newVal = val;
    if(val.length > 20){

      newVal = val.substring(0,20) + "...";
    }

    return "<span title='"+val+"'> " + newVal + " </span>";
  }

  function loadSuccess() {


  }

  function f_optDetail(quesId){
    var rowsData = $('#businessList').datagrid('getSelections');

    setTimeout(function(){
      var title = rowsData[0]['customer.nickname'] + '的问答详情';

      if(title.length > 23){
        title = title.substring(0,23) + "...";
      }

      if(li_east == 0){
        $('#main_typegroup_list').layout('expand','east');
      }
      $('#main_typegroup_list').layout('panel','east').panel('setTitle', title);
      $('#listpanel').panel("refresh", "questionsController.do?commentList&quesId=" + quesId );
    },10);

  }

</script>
